<?php
  class Course
{
   private $id;
   private $courseName;
   private $courseHour;
   private $major;

   public function __construct($id,$courseName,$courseHour,$major){
       
       $this->setId($id);
       $this->setCourseName($courseName);
       $this->setCourseHour($courseHour);
       $this->setMajor($major);

   }
    
   public function __get($name){
      $m='get'.ucfirst(strtolower($name));
      if (method_exists($this, $m)) {
      	return $this->$m();
      }
      echo '方法 ' . $m . ' 不存在';
       return false;
   }
    public function __set($name,$value){
       $m='set'.ucfirst(strtolower($name));
       if (method_exists($this, $m)) {
      	$this->$m($value);
      }
       
    }
   public function printInfo(){
   	 echo 'id'.$this->getId().'课程名称'.$this->getCourseName().'课时数'.$this->getCourseHour().'专业'.$this->getMajor();
   }

   private function getId(){
   	return $this->id;
   }

   private function setId($id){
    if (is_integer($id)) {
    	$this->id=$id;
    }
   }

   private function getCourseName(){
   	  return $this->courseName;
   }

   private function setCourseName($courseName){
   	 if (is_string($courseName)) {
   	 	$this->courseName=$courseName;
   	 }
   }

   private  function getCourseHour(){
   	return $this->courseHour;
   }

   private  function setCourseHour($courseHour){
     if (is_integer($courseHour)) {
     	$this->courseHour=$courseHour;
     }
   }
   private  function  getMajor(){
      return $this->major;
   }
   
   private  function  setMajor($major){
      if (is_string($major)) {
      	$this->major=$major;
      }
   }
}